package com.zt.english.activity.video

import android.view.KeyEvent
import cn.jzvd.JzvdStd
import com.gyf.immersionbar.ImmersionBar
import com.zt.english.R
import com.zt.english.databinding.ActivityVideoPlayBinding
import com.zt.mvvm.view.BaseActivity
import com.zt.mvvm.view.BaseLifeCycleActivity

/**
 * 视频播放界面
 */
class VideoPlayActivity : BaseActivity<VideoPlayViewModel,ActivityVideoPlayBinding>(){



    override fun initImmersionBar() {
        ImmersionBar.with(this)
            .statusBarDarkFont(false)
            .navigationBarColor(R.color.color_navigation)
            .titleBar(mDataBinding.jzVideo.topContainer)//解决状态栏与布局标题重叠问题
            .init()
    }

    //全屏视频退出处理
    override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (JzvdStd.backPress()) {
                return true
            }
        }
        return super.onKeyDown(keyCode, event)
    }

    //界面遮挡，暂停播放
    override fun onPause() {
        super.onPause()
        JzvdStd.goOnPlayOnPause()
    }
    //恢复播放状态(之前播放就播放，暂停则暂停)
    override fun onResume() {
        super.onResume()
        JzvdStd.goOnPlayOnResume()
    }
    override fun onDestroy() {
        super.onDestroy()
        //退出任然继续播放/暂停
        JzvdStd.goOnPlayOnResume()
    }
}